/**
 * 
 */
package com.cait.dutyfree.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

/**
 * @author Rasika Kaluwalgoda
 * 
 */
@Entity
@Table(name = "products")
public class Product implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	private String code;
	private String name;
	private String description;
	private String prdImageUrl1;
	private String prdImageUrl2;
	private String prdImageUrl3;
	private String vendor;
	private Integer reOrderLevel;
	private Integer clt; // Critical Lower Threshold
	private Boolean status;

	private Category category;
	private SubCategory subCategory;
	private List<AirlineProduct> airlineProducts = new ArrayList<AirlineProduct>();

	/**
	 * @return the prdId
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	/**
	 * @param prdId
	 *            the prdId to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the prdImageUrl1
	 */
	public String getPrdImageUrl1() {
		return prdImageUrl1;
	}

	/**
	 * @param prdImageUrl1
	 *            the prdImageUrl1 to set
	 */
	public void setPrdImageUrl1(String prdImageUrl1) {
		this.prdImageUrl1 = prdImageUrl1;
	}

	/**
	 * @return the prdImageUrl2
	 */
	public String getPrdImageUrl2() {
		return prdImageUrl2;
	}

	/**
	 * @param prdImageUrl2
	 *            the prdImageUrl2 to set
	 */
	public void setPrdImageUrl2(String prdImageUrl2) {
		this.prdImageUrl2 = prdImageUrl2;
	}

	/**
	 * @return the prdImageUrl3
	 */
	public String getPrdImageUrl3() {
		return prdImageUrl3;
	}

	/**
	 * @param prdImageUrl3
	 *            the prdImageUrl3 to set
	 */
	public void setPrdImageUrl3(String prdImageUrl3) {
		this.prdImageUrl3 = prdImageUrl3;
	}

	/**
	 * @return the vendor
	 */
	public String getVendor() {
		return vendor;
	}

	/**
	 * @param vendor
	 *            the vendor to set
	 */
	public void setVendor(String vendor) {
		this.vendor = vendor;
	}

	/**
	 * @return the reOrderLevel
	 */
	public Integer getReOrderLevel() {
		return reOrderLevel;
	}

	/**
	 * @param reOrderLevel
	 *            the reOrderLevel to set
	 */
	public void setReOrderLevel(Integer reOrderLevel) {
		this.reOrderLevel = reOrderLevel;
	}

	/**
	 * @return the clt
	 */
	public Integer getClt() {
		return clt;
	}

	/**
	 * @param clt
	 *            the clt to set
	 */
	public void setClt(Integer clt) {
		this.clt = clt;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Boolean getStatus() {
		return status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	/**
	 * @return the category
	 */
	@OneToOne(cascade = CascadeType.ALL)
	public Category getCategory() {
		return category;
	}

	/**
	 * @param category
	 *            the category to set
	 */
	public void setCategory(Category category) {
		this.category = category;
	}

	/**
	 * @return the subCategory
	 */
	@OneToOne(cascade = CascadeType.ALL)
	public SubCategory getSubCategory() {
		return subCategory;
	}

	/**
	 * @param subCategory
	 *            the subCategory to set
	 */
	public void setSubCategory(SubCategory subCategory) {
		this.subCategory = subCategory;
	}

	/**
	 * @return the airlineDetails
	 */
	@OneToMany(mappedBy = "product", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	public List<AirlineProduct> getAirlineProducts() {
		return airlineProducts;
	}

	/**
	 * @param airlineDetails
	 *            the airlineDetails to set
	 */
	public void setAirlineProducts(List<AirlineProduct> airlineProducts) {
		this.airlineProducts = airlineProducts;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Product) {
			Product other = (Product) obj;
			if (this.id != 0 && other.id != 0 && this.id.intValue() == other.id.intValue()) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

}
